<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-us">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrom=1">
	<meta http-equiv="Cache-Control" content="no-store"/>
	<meta http-equiv="Pragma" content="no-cache"/>
	<meta http-equiv="Expires" content="0"/>
 	<%@ include file="../base.jsp" %>
	<title>转结列表</title>
	 <script type="text/javascript" >
$(document).ready(function() {
 
  //初始化日期样式
    $(".datepicker").datepicker({
           language: "zh-CN",
           autoclose: true,//选中之后自动隐藏日期选择框
           clearBtn: true,//清除按钮
           todayBtn:'linked',//今日按钮
           format: "yyyy-mm-dd"//日期格式
    });
    /**开关按钮**/
	// 1 已结一  2未结 
    $("#mark_switch").bootstrapSwitch();
    $("#mark_switch").on('switchChange.bootstrapSwitch', function(event, state) {
        	if (state==true){
        	    $("#mark").val("1");  
        	}else{
        		$("#mark").val("2"); 
        	}
        });
    /**开关按钮end**/
    $("#mark").val("${page.mark}");
    if("${page.mark}"==1){
    	$("#mark_switch").bootstrapSwitch('state',true, true);
    }else if("${page.mark}"==2){
    	$("#mark_switch").bootstrapSwitch('state',false, false);
    }
    var count=0;
    $("span[id=amount]").each(function(){
    	count+=parseFloat($(this).text());
    });
    $("span[id=showcount]").text("总共："+count+" ￥");
    
	$("#check").click(function(){
		$("[name=ids]").each(function(){$(this).attr("checked", !$(this).attr("checked"));});
	});
});







</script>
	
	
</head>
<body>
  <div class="con_wrap">
  	<%@ include file="../head.jsp" %>
     <div id="main">
		<form id="queryForm" action="${ctx}/sell/transfer.do" name="queryForm" method="post" style="display: inline;">
			<div id="main">
				<dl class="section_wrap">
					<dt><h2>搜索</h2></dt>
					<dd class="dd">
						<table class="form">
							<tr>
								<td class="tit">日   期：</td>		
								<td>
									  <input type="text" class="datepicker" name="date" id="date" value="<fmt:formatDate value='${page.date}' pattern="yyyy-MM-dd"/>"/>
									~ <input type="text" class="datepicker" name="dateEnd" id="dateEnd" value="<fmt:formatDate value='${page.dateEnd}' pattern="yyyy-MM-dd"/>"/>
								</td>
								　
								<td class="tit">支付方式</td>
									<td class="SELECT">
										<select name="payType" id="payType"
											class="chzn-select-deselect w20" data-placeholder="Choose a pay....">
												<option value=""></option>
												<c:forEach items="${payTypeList}" var="p">
													<option value="${p.id}"  <c:if test="${p.id==page.payType}"> selected </c:if> >${p.paymethod}</option>
												</c:forEach>
										</select>
								</td>
							</tr>
							<tr>
 								<td class="tit">状　态：</td>
								   	<td><input type="checkbox" id="mark_switch" data-size="mini"data-on-text="已结" data-off-text="未结">  
										<input type="hidden" id="mark" name="mark" />
									</td>
								<td class="tit">　　</td>
								<td>
									<input name="Input" class="button blue" value="搜索" onclick="getReferenceForm(this).action='${ctx}/sell/transfer.do'" type="submit"/>
								</td>
							</tr>
						</table>
					</dd>
				</dl>
				<dl class="section_wrap">
					<dt><h2>账目列表</h2></dt>
					<dd class="dd">
						<table class="grid">
							<thead>
							  <tr>
								<th style="text-align:center;" >id</th>
								<th style="text-align:center;" >日　期</th>
								<th style="text-align:center;" >金　额</th>
								<th style="text-align:center;" >支　付</th>
								<th style="text-align:center;" >状　态</th>
								<th style="width: 120px;text-align:center;" >
									<input type="button" style="width: 40px;" class="button blue"  id="check" value="选择" >
									<button value="" style="width: 40px;" class="button blue">转结</button>
									
								</th>
							  </tr>
						  </thead>
						  <tbody>
						   <c:forEach items="${page.result}" var="collection" varStatus="status">
							  <tr class="${status.count % 2 == 0 ? 'odd' : 'even'}" style="text-align:center;"  >
								<td>${collection.id}</td>
								<td>${collection.date}</td>
								<td><span id="amount"> ${collection.amount}</span>￥</td>
								<td>
									<c:forEach items="${payTypeList }" var="p">
											<c:if test="${p.id==collection.payType}"> ${p.paymethod} </c:if>
									</c:forEach>
								</td>
								<td>
									<c:choose>
										<c:when test="${collection.mark==1}">已结</c:when>
										<c:otherwise>未结</c:otherwise>
									</c:choose>
									 
								</td>
								<td>
									<input type="checkbox" name="ids" value="${collection.id}">
								</td>
							 </tr>
			  	  			</c:forEach>
			  	  			 <tr style="text-align:center;">
			  	  			 	<td></td>
								<td></td>
								<td><span id="showcount"></span></td>
								<td></td>
								<td></td>
								<td></td>
			  	  			 </tr>
						  </tbody>
						</table>
						<!--  -->
						<%@ include file="../pagebar.jsp" %>
						<input type="hidden" id="url" value="${page.url}/list.do">
					</dd>
				</dl>
			</div>
		</form>
	</div>
	<div style="height: 200px;">
</div>
	<div id="footer">
		<%@ include file="../footer.jsp" %>
	</div>
</div>
</body>
</html>	